package com.jzqf.harmonydemo.views.slice;

import com.jzqf.harmonydemo.ResourceTable;
import com.jzqf.harmonydemo.base.BaseAbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.Text;

public class TextAbilitySlice extends BaseAbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        setTitle("Text");
        initView();
    }

    @Override
    protected int getLayoutResId() {
        return ResourceTable.Layout_ability_text;
    }

    private void initView() {
        //跑马灯
        Text autoScrolling = (Text) findComponentById(ResourceTable.Id_autoScrolling_text);
        autoScrolling.setAutoScrollingCount(Text.AUTO_SCROLLING_FOREVER);
        autoScrolling.startAutoScrolling();
        //自动调节字体大小
        Text autoFrontSize = (Text) findComponentById(ResourceTable.Id_autoFrontSize_text);
        autoFrontSize.setAutoFontSizeRule(30, 100, 1);
        autoFrontSize.setClickedListener(component -> autoFrontSize.setText(autoFrontSize.getText() + "小"));
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
